package com.dyit.springcloud.hospital.plan.config;

import com.dyit.springcloud.hospital.plan.job.AppQuartz;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzConfig {

    @Bean
    public JobDetail jobDetail(){
        return JobBuilder.newJob(AppQuartz.class)
                .withIdentity("myJob")
                .storeDurably().build();
    }

    @Bean
    public Trigger jobTrigger(){
        Trigger trigger = TriggerBuilder
                .newTrigger()
                .forJob(jobDetail())
                .withIdentity("test","triggerGroup")
                .withSchedule(CronScheduleBuilder.cronSchedule("0 05 12 * * ? *"))
                .startNow().build();

        return trigger;

    }
}
